import sys;
sys.path.append('..');
from by.vaukalak.core.events.EventDispatcher import *;
import time;


class Application:

    enterFrameDispatcher = EventDispatcher();

    def __init__(self):
        self._fps = 30;
        self.onAppStart();
        fpsPeriod = 1.000 / self._fps;
        while 1:
            enterFrameTime = time.time();
            Application.enterFrameDispatcher.dispatchEvent(Event("enterFrame"));
            frameExecutionTime = (time.time() - enterFrameTime);
            time.sleep(max(fpsPeriod - frameExecutionTime,0));

    def onAppStart(self):
        print "application start";

    def print_some(e):
        print(e.target);
